cmake_minimum_required(VERSION 3.5)

# 项目环境配置 ###########################################################################################################
project(hello-qt VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# qt 库 ################################################################################################################
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# vcpkg ################################################################################################################
set(vckpg_dir "/home/laolang/program/vcpkg")
set(CMAKE_TOOLCHAIN_FILE "${vckpg_dir}/scripts/buildsystems/vcpkg.cmake")
set(fmt_DIR "${vckpg_dir}/packages/fmt_x64-linux-dynamic/share/fmt")
set(spdlog_DIR "${vckpg_dir}/packages/spdlog_x64-linux-dynamic/share/spdlog")

# fmt 库
find_package(fmt CONFIG REQUIRED)
get_target_property(fmt_LOCATION fmt::fmt LOCATION)
get_filename_component(fmt_DIRECTORY ${fmt_LOCATION} DIRECTORY)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    string(REPLACE "debug/" "" fmt_DIRECTORY ${fmt_DIRECTORY})
endif()

message(STATUS "fmt_DIRECTORY:${fmt_DIRECTORY}")

# spdlog 库
find_package(spdlog CONFIG REQUIRED)
get_target_property(spdlog_LOCATION spdlog::spdlog LOCATION)
get_filename_component(spdlog_DIRECTORY ${spdlog_LOCATION} DIRECTORY)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    string(REPLACE "debug/" "" spdlog_DIRECTORY ${spdlog_DIRECTORY})
endif()

message(STATUS "spdlog_DIRECTORY:${spdlog_DIRECTORY}")

# 项目变量配置 ###########################################################################################################
set(QRC_FILES ${PROJECT_SOURCE_DIR}/res.qrc)

set(person_lib_name person)
set(util_lib_name util)

# 添加子目录 #############################################################################################################
add_subdirectory(src)
